<?php
include("interface.class.php");
include("table.class.php");
include("database.class.php");

$inf = new webinterface();
$inf->set_title("Edit Proxy Group");

$db = new database();
$link = $db->connect();

$res = mysql_query("SELECT * FROM proxy_group WHERE idproxy_group='" . $_GET['idproxy_group'] . "'", $link);
$row = mysql_fetch_array($res);
$inf->set_title("Edit Host Group (" . $row['name'] . ")");
if ($row['type'] == "dynamic"){
	$filters = array("TEST_VALUE", "OPERATOR");	
} else {
	$filters = array("PROXY");
}

$res = mysql_query("SELECT * FROM proxy_group_members INNER JOIN properties ON proxy_group_members.idc_property=properties.idproperty WHERE idc_proxy_group='" . $_GET['idproxy_group'] . "' GROUP BY proxy_group_members.group_order", $link);
$inf->add_content("<form id='proxy_group'>");
while ($row = mysql_fetch_array($res)) {
	$inf->add_content("<select name='property" . $row['idproxy_group_members'] . "'>");
	foreach ($filters as $f){
		if($f == $row['property']){
			$inf->add_content("<option name='property" . $row['idproxy_group_members'] . "' selected='selected' value='" . $f . "' >" . $f . "</option>");
		} else {
			$inf->add_content("<option name='property" . $row['idproxy_group_members'] . "' value='" . $f . "' >" . $f . "</option>");
		}
	}
	$inf->add_content("</select>");
	$inf->add_content(" <input type='text' name='value" . $row['idproxy_group_members'] . "' value='" . $row['value'] . "' />");
	$inf->add_content(" <input type='button' name='delete" . $row['idproxy_group_members'] . "' value='Delete' />");
	$inf->add_content("<br/>");
}
$inf->add_content("</form>");
mysql_close($link);

$inf->commit();
?>
